package com.app.service.impl;


import com.app.mapper.UpperSchoolMapper;
import com.app.model.UpperSchoolModel;
import com.app.service.UpperSchoolService;
import com.app.util.StringTool;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @Description:高校
 * @Author: N
 * @Date: 2022年11月24日 10点29分
 */
@Service
public class UpperSchoolServiceImpl implements UpperSchoolService {
    @Autowired
    UpperSchoolMapper upperSchoolMapper;
    @Override
    public List<UpperSchoolModel> getSchool(String keyword) {
        if(StringTool.isEmpty(keyword)){
            return null;
        }
        QueryWrapper<UpperSchoolModel> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("id","school_name").like("school_name",keyword);
        return upperSchoolMapper.selectList(queryWrapper);
    }

    @Override
    public List<UpperSchoolModel> getSchoolAll() {
        QueryWrapper<UpperSchoolModel> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("id","school_name");
        return upperSchoolMapper.selectList(queryWrapper);
    }

    @Override
    public UpperSchoolModel getModelById(Integer id) {
        QueryWrapper<UpperSchoolModel> queryWrapper = new QueryWrapper<>();
        queryWrapper.select().eq("id", id);
        UpperSchoolModel model = upperSchoolMapper.selectOne(queryWrapper);
        return model;
    }
}
